import Vue from "vue";
import VueRouter from "vue-router";

import home from "@/views/home/index.vue";
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/home",
    name: "home",
    component: home,
    mate: {
      tagName: "首页",
    },
  },
  {
    path: "/exmple",
    name: "exmple",
    component: () => import("@/views/exmple/index.vue"),
    mate: {
      tagName: "示例",
    },
  },
  {
    path: "/manage",
    name: "manage",
    component: () => import("@/views/manage/index.vue"),
    mate: {
      tagName: "管理",
    },
    scrollBehavior(t){
      console.log(t);
    }
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
  // scrollBehavior: (to, from, savedPosition) => {
    
  //   if (to.hash) {
  //     // 有 hash 值就返回 hash的
  //     return {
  //       selector: to.hash,
  //     };
  //   }

  //   if (savedPosition) {
  //     return savedPosition;
  //   }
  // },
});

export default router;
